#ifndef TIMEWIDGET_H
#define TIMEWIDGET_H

#include <QWidget>
#include <QDebug>
#include <QDateTime>
#include <QLabel>

#include "rollingbox.h"

class TimeWidget : public QWidget
{
    Q_OBJECT
public:
    explicit TimeWidget(QWidget *parent = nullptr);

    void setDateTime(const QDateTime & dateTime);
    QDateTime getDateTime(void) const { return m_dateTime; }

signals:
    void valueChangeSign(void);

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void valueChangeSlot(int value);

private:
    static int monthToDay(int year, int month);
    void setMaxDay(int year, int month);

private:
    RollingBox * m_yearRolling;
    RollingBox * m_monthRolling;
    RollingBox * m_dayRolling;
    RollingBox * m_hourRolling;
    RollingBox * m_minRolling;
    RollingBox * m_secRolling;

    QLabel * m_ymLabel;
    QLabel * m_mdLabel;
    QLabel * m_hmLabel;
    QLabel * m_msLabel;

    QDateTime m_dateTime;
    int m_minYear = 1990, m_maxYear = 2090;
};

#endif // TIMEWIDGET_H
